
<div class="container">
<?php
if (empty($datalist)) {
	echo "<h3>Data masih kosong!</h3>";
}
else {
?>
			<table id="my_data_list" class="table table-striped table-bordered" cellspacing="0" width="100%">
				<thead>
					<tr>
						<th>No</th>
						<th>Bagian</th>
						<th>Temuan</th>
						<th>Jumlah</th>
						<th>Status Open</th>
						<th>Status On Progress</th>
						<th>Status Selesai</th>
						<th>Keterangan</th>
					</tr>
				</thead>
				<tbody>
				<?php
				$no = 1;
				$s_jumlah=0; $s_progress=0; $s_selesai=0; $s_open=0;
				$k_jumlah=0; $k_progress=0; $k_selesai=0; $k_open=0;
				$g_jumlah=0; $g_progress=0; $g_selesai=0; $g_open=0;
				foreach ($datalist as $data):
				
				if(!empty($data->S1)) { $s_jumlah++; if($data->RTLS1==1) { $s_progress++; } else if($data->RTLS1==3) { $s_open++; } else { $s_selesai++; } }
				if(!empty($data->S2)) { $s_jumlah++; if($data->RTLS2==1) { $s_progress++; } else if($data->RTLS2==3) { $s_open++; } else { $s_selesai++; } }
				if(!empty($data->S3)) { $s_jumlah++; if($data->RTLS3==1) { $s_progress++; } else if($data->RTLS3==3) { $s_open++; } else { $s_selesai++; } }
				if(!empty($data->S4)) { $s_jumlah++; if($data->RTLS4==1) { $s_progress++; } else if($data->RTLS4==3) { $s_open++; } else { $s_selesai++; } }
				if(!empty($data->S5)) { $s_jumlah++; if($data->RTLS5==1) { $s_progress++; } else if($data->RTLS5==3) { $s_open++; } else { $s_selesai++; } }
				
				if(!empty($data->K1)) { $k_jumlah++; if($data->RTLK1==1) { $k_progress++; } else if($data->RTLK1==3) { $k_open++; } else { $k_selesai++; } }
				if(!empty($data->K2)) { $k_jumlah++; if($data->RTLK2==1) { $k_progress++; } else if($data->RTLK2==3) { $k_open++; } else { $k_selesai++; } }
				if(!empty($data->K3)) { $k_jumlah++; if($data->RTLK3==1) { $k_progress++; } else if($data->RTLK3==3) { $k_open++; } else { $k_selesai++; } }
				if(!empty($data->K4)) { $k_jumlah++; if($data->RTLK4==1) { $k_progress++; } else if($data->RTLK4==3) { $k_open++; } else { $k_selesai++; } }
				if(!empty($data->K5)) { $k_jumlah++; if($data->RTLK5==1) { $k_progress++; } else if($data->RTLK5==3) { $k_open++; } else { $k_selesai++; } }
				
				if(!empty($data->G1)) { $g_jumlah++; if($data->RTLG1==1) { $g_progress++; } else if($data->RTLG1==3) { $g_open++; } else { $g_selesai++; } }
				if(!empty($data->G2)) { $g_jumlah++; if($data->RTLG2==1) { $g_progress++; } else if($data->RTLG2==3) { $g_open++; } else { $g_selesai++; } }
				if(!empty($data->G3)) { $g_jumlah++; if($data->RTLG3==1) { $g_progress++; } else if($data->RTLG3==3) { $g_open++; } else { $g_selesai++; } }
				if(!empty($data->G4)) { $g_jumlah++; if($data->RTLG4==1) { $g_progress++; } else if($data->RTLG4==3) { $g_open++; } else { $g_selesai++; } }
				if(!empty($data->G5)) { $g_jumlah++; if($data->RTLG5==1) { $g_progress++; } else if($data->RTLG5==3) { $g_open++; } else { $g_selesai++; } }
				?>
					<tr>
						<td><?php echo $no; ?></td>
						<td><?php echo $data->BAGIAN; ?></td>
						<td>Sikap Tidak Aman</td>
						<td><?php echo $s_jumlah; ?></td>
						<?php
						if($s_jumlah==0)
						{
						?>
						<td><?php echo "0 %"; ?></td>
						<td><?php echo "0 %"; ?></td>
						<td><?php echo "0 %"; ?></td>
						<?php
						}
						else
						{
						?>
						<td><?php echo substr($s_open/$s_jumlah*100,0,4); echo " %"; ?></td>
						<td><?php echo substr($s_progress/$s_jumlah*100,0,4); echo " %"; ?></td>
						<td><?php echo substr($s_selesai/$s_jumlah*100,0,4); echo " %"; ?></td>
						<?php
						}
						?>
						<td><?php echo "-"; ?></td>
					</tr>
					<tr>
						<td><font color="white"><?php echo $no; ?></font></td>
						<td></td>
						<td>Kondisi Tidak Aman</td>
						<td><?php echo $k_jumlah; ?></td>
						<?php
						if($k_jumlah==0)
						{
						?>
						<td><?php echo "0 %"; ?></td>
						<td><?php echo "0 %"; ?></td>
						<td><?php echo "0 %"; ?></td>
						<?php
						}
						else
						{
						?>
						<td><?php echo substr($k_open/$k_jumlah*100,0,4); echo " %"; ?></td>
						<td><?php echo substr($k_progress/$k_jumlah*100,0,4); echo " %"; ?></td>
						<td><?php echo substr($k_selesai/$k_jumlah*100,0,4); echo " %"; ?></td>
						<?php
						}
						?>
						<td><?php echo "-"; ?></td>
					</tr>
					<tr>
						<td><font color="white"><?php echo $no; ?></font></td>
						<td></td>
						<td>Lingkungan Kerja</td>
						<td><?php echo $g_jumlah; ?></td>
						<?php
						if($g_jumlah==0)
						{
						?>
						<td><?php echo "0 %"; ?></td>
						<td><?php echo "0 %"; ?></td>
						<td><?php echo "0 %"; ?></td>
						<?php
						}
						else
						{
						?>
						<td><?php echo substr($g_open/$g_jumlah*100,0,4); echo " %"; ?></td>
						<td><?php echo substr($g_progress/$g_jumlah*100,0,4); echo " %"; ?></td>
						<td><?php echo substr($g_selesai/$g_jumlah*100,0,4); echo " %"; ?></td>
						<?php
						}
						?>
						<td><?php echo "-"; ?></td>
					</tr>
				<?php
				$no++;
				endforeach;
				?>
				</tbody>
			</table>
<?php
}
?>
		</div>
		</body></html>